package com.ruoyi.idea.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.idea.service.IIdeaService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.idea.domain.Idea;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 评价管理Controller
 * 
 * @author ruoyi
 * @date 2024-06-06
 */
@RestController
@RequestMapping("/idea/idea")
public class IdeaController extends BaseController
{
    @Autowired
    private IIdeaService ideaService;

    /**
     * 查询评价管理列表
     */
    @PreAuthorize("@ss.hasPermi('idea:idea:list')")
    @GetMapping("/list")
    public TableDataInfo list(Idea idea)
    {
        startPage();
        List<Idea> list = ideaService.selectIdeaList(idea);
        return getDataTable(list);
    }

    /**
     * 导出评价管理列表
     */
    @PreAuthorize("@ss.hasPermi('idea:idea:export')")
    @Log(title = "评价管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Idea idea)
    {
        List<Idea> list = ideaService.selectIdeaList(idea);
        ExcelUtil<Idea> util = new ExcelUtil<Idea>(Idea.class);
        util.exportExcel(response, list, "评价管理数据");
    }

    /**
     * 获取评价管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('idea:idea:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ideaService.selectIdeaById(id));
    }

    /**
     * 新增评价管理
     */
    @PreAuthorize("@ss.hasPermi('idea:idea:add')")
    @Log(title = "评价管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Idea idea)
    {
        return toAjax(ideaService.insertIdea(idea));
    }

    /**
     * 修改评价管理
     */
    @PreAuthorize("@ss.hasPermi('idea:idea:edit')")
    @Log(title = "评价管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Idea idea)
    {
        return toAjax(ideaService.updateIdea(idea));
    }

    /**
     * 删除评价管理
     */
    @PreAuthorize("@ss.hasPermi('idea:idea:remove')")
    @Log(title = "评价管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ideaService.deleteIdeaByIds(ids));
    }
}
